package at.sysarch.bean;

import java.io.File;

import at.pimpmypipe.interfaces.Readable;
import at.sysarch.domain.TransferImage;
import at.sysarch.filter.StoreFilter;
import at.sysarch.utils.LinkEvent;
import at.sysarch.utils.LinkListener;

public class Store extends AbstractBean<StoreFilter> implements LinkListener {

	private static final long serialVersionUID = 1L;

	public Store() {
		_filter = new StoreFilter(this);
	}

	@Override
	public void linkBean(LinkEvent event) {
		_filter.setInput(event.getInput());
		event.getInput().setOutput(_filter);
		_filter.run();
	}

	@Override
	public void addLinkListener(LinkListener listener) {
		listener.linkBean(new LinkEvent((Readable<TransferImage>)_filter));
	}

	@Override
	public void removeLinkListener(LinkListener listener) {	
		
	}
	
	public String getFile() {
		return _filter.getFile() != null ? _filter.getFile().getAbsolutePath() : "Select file";
	}

	public void setFile(String file) {
		_filter.setFile(new File(file));
	}
}
